package utils.core;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import javax.swing.JOptionPane;

/**
 *
 * @author Juan Carlos García
 */
public class CoreUtils {

    /**
     * This method puts the data syntaxis taked from the syntaxis file in the
     * core folder.
     * 
     * @return Object[][] with the correct data from core
     */
    public static Object[][] getPropertiesToReplace(){
        
        try{
        
        FileInputStream fstream = new FileInputStream("src/core/syntax");
        DataInputStream in = new DataInputStream(fstream);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String strLine = "";
        int numLines = 0;
        while ((strLine = br.readLine()) != null)   {
                numLines++;
        }
        String[] lines = new String[numLines];
        FileInputStream fstream2 = new FileInputStream("src/core/syntax");
        DataInputStream in2 = new DataInputStream(fstream2);
        BufferedReader br2 = new BufferedReader(new InputStreamReader(in2));
        int i = 0;
        while ((strLine = br2.readLine()) != null)   {
                lines[i] = strLine;
                i++;
        }
        
        String[][] data = new String[lines.length][2];
        for(int x=0;x<lines.length;x++){
            for(int y=0;y<2;y++){
                if(y!=1){
                    data[x][y] = lines[x];
                }else{
                    data[x][y] = "";
                }
                
            }
        }
        
        return data;
        
        }catch(Exception e2){
            JOptionPane.showMessageDialog(null, e2.getMessage());
            return null;
        }
    }
    
}
